package com.github.catvod.spider.merge;

import android.text.TextUtils;
import java.io.IOException;
import java.util.Map;
import okhttp3.Call;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

class g {
  private final L BQ;
  
  private final String I;
  
  private String V0;
  
  private Request W;
  
  private final String h;
  
  private Object j = null;
  
  private final Map<String, String> oC;
  
  private final Map<String, String> q;
  
  private Request.Builder u;
  
  g(String paramString1, String paramString2, String paramString3, Map<String, String> paramMap, L paramL) {
    this(paramString1, paramString2, paramString3, null, paramMap, paramL);
  }
  
  private g(String paramString1, String paramString2, String paramString3, Map<String, String> paramMap1, Map<String, String> paramMap2, L paramL) {
    this.h = paramString1;
    this.V0 = paramString2;
    this.I = paramString3;
    this.q = paramMap1;
    this.oC = paramMap2;
    this.BQ = paramL;
    V0();
  }
  
  g(String paramString1, String paramString2, Map<String, String> paramMap1, Map<String, String> paramMap2, L paramL) {
    this(paramString1, paramString2, null, paramMap1, paramMap2, paramL);
  }
  
  private void I() {
    Map<String, String> map = this.oC;
    if (map != null)
      for (String str : map.keySet())
        this.u.addHeader(str, this.oC.get(str));  
  }
  
  private void V0() {
    this.u = new Request.Builder();
    String str = this.h;
    str.hashCode();
    if (!str.equals("GET")) {
      if (str.equals("POST"))
        this.u.post(j()); 
    } else {
      q();
    } 
    this.u.url(this.V0);
    Object object = this.j;
    if (object != null)
      this.u.tag(object); 
    if (this.oC != null)
      I(); 
    this.W = this.u.build();
  }
  
  private RequestBody j() {
    if (!TextUtils.isEmpty(this.I))
      return RequestBody.create(MediaType.parse("application/json; charset=utf-8"), this.I); 
    FormBody.Builder builder = new FormBody.Builder();
    Map<String, String> map = this.q;
    if (map != null)
      for (String str : map.keySet())
        builder.add(str, this.q.get(str));  
    return (RequestBody)builder.build();
  }
  
  private void q() {
    if (this.q != null) {
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append(this.V0);
      stringBuilder.append("?");
      this.V0 = stringBuilder.toString();
      for (String str1 : this.q.keySet()) {
        stringBuilder = new StringBuilder();
        stringBuilder.append(this.V0);
        stringBuilder.append(str1);
        stringBuilder.append("=");
        stringBuilder.append(this.q.get(str1));
        stringBuilder.append("&");
        this.V0 = stringBuilder.toString();
      } 
      String str = this.V0;
      this.V0 = str.substring(0, str.length() - 1);
    } 
  }
  
  void h(OkHttpClient paramOkHttpClient) {
    Call call = paramOkHttpClient.newCall(this.W);
    try {
      Response response = call.execute();
      L l = this.BQ;
      if (l != null)
        l.h(call, response); 
    } catch (IOException iOException) {
      L l = this.BQ;
      if (l != null)
        l.onError(call, iOException); 
    } 
  }
  
  public void oC(Object paramObject) {
    this.j = paramObject;
  }
}


/* Location:              /Users/hetaiyi/Desktop/my/tech/java/study/aa/temp/temp.jar!/com/github/catvod/spider/merge/g.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */